package com.future.wxapp.common.util;
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
/**
 * 发送短信
 * @author li
 * @date 2020-1-16
 */
public class SendSmsUtil {
    public int Send(){
        int result = 0;
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "LTAI4FxRXKMowFcg3mfZJpiM", "PB19iTfyyMf4VZUaa7MNd91HPzozCm");
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setMethod(MethodType.POST);
        request.setDomain("dysmsapi.aliyuncs.com");
        request.setVersion("2017-05-25");
        request.setAction("SendSms");
        request.putQueryParameter("RegionId", "cn-hangzhou");
        request.putQueryParameter("PhoneNumbers", "15023275475");
        request.putQueryParameter("SignName", "集力合创");
        request.putQueryParameter("TemplateCode", "SMS_182670918");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
            result = 1;
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
        return result;
    }
}
